// Created by WXX on 2021/8/31 9:24
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    vector<int> corpFlightBookings(vector<vector<int>> &bookings, int n) {
        vector<int> t(n + 10);
        for (auto &item : bookings) {
            int a = item[0], b = item[1], w = item[2];
            t[a] += w, t[b + 1] -= w;
        }
        vector<int> res;
        for (int i = 1; i <= n; i++) {
            t[i] += t[i - 1];
            res.push_back(t[i]);
        }
        return res;
    }
};

void OutputBasicArray1D(vector<int> nums) {
    cout << "[";
    for (int i = 0; i < nums.size(); i++) {
        cout << nums[i];
        if (i != nums.size() - 1) cout << ", ";
    }
    cout << "]" << endl;
}

int main() {

    vector<vector<int>> bookings = {
            {1, 2, 10},
            {2, 3, 20},
            {2, 5, 25}
    };
    OutputBasicArray1D(Solution().corpFlightBookings(bookings, 5));  // [10, 55, 45, 25, 25]

    return 0;
}
